package test.iso
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.Point;
	
	import level4.display.GameDispose;
	import level4.engines.GameEngine;
	import level4.iso.DrawnIsoTile;
	import level4.iso.IsoUtil;
	import level4.iso.Point3D;

	public class IsoTest extends GameDispose
	{
		public const TILE_WIDTH:int = 20;
		
		public function IsoTest()
		{
			for(var i:int = 0;i<10;i++){
				for(var j:int = 0;j<1;j++){
					var tile:DrawnIsoTile = new DrawnIsoTile(20,0xcccccc,0);
						tile.IsoPoint = new Point3D(i * TILE_WIDTH,0,j * TILE_WIDTH);
					addChild(tile);
					//加入引擎
					GameEngine.addComponent(tile);
				}
			}
		}
		
		override public function init(e:Event):void{
			stage.addEventListener(MouseEvent.CLICK,onClick);
		}
		private function onClick(e:MouseEvent):void{
			var pt:Point = IsoUtil.ScreenToGrid(new Point(e.stageX,e.stageY),TILE_WIDTH);
			trace(pt);
		}
	}
}